Using the evaltrace style

Basically, the evaltrace and code options define new environments (called evaltrace and code) which behave much like verbatim, except that certain characters and character sequences are interpreted in a special way. The code environment is almost exactly like verbatim (, spaces and line breaks are respected, and characters are set in teletype font), except that the backslash (``\'') and dollar-sign (``$'') characters are still interpreted specially. So, for example, the following input:

    \begin{code}
    {\bf procedure} foo ({\bf var} x: integer);
      {\bf begin}
          x := $\sum{\tt a}_{i}$
      {\bf end}l
    \end{code}
produces the following output:
\begin{code}
{\bf procedure} foo ({\bf var} x: integer);
{\bf begin}
x := $\sum{\tt a}_{i}$
{\bf end};
\end{code}
This environment will also ensure that no page breaks occur in the middle of the output. For multi-page code output, the ``bigcode'' environment should be used instead of ``code.''

The evaltrace style loads a special fixed-width font called ``et,'' which has the special characters for drawing evaltrace diagrams. In the et font, various ASCII characters are mapped to et characters, for example, saying {\et -} produces the evaltrace horizontal thin rule, -, {\et >} produces >, and {\et -->} produces –>. Section [*] gives a complete listing of the et font. This font makes it possible to draw simple evaltrace diagrams in the code environment, as in the following:

    \begin{code}
    (+ 2 3) {\et -->} 5
    \end{code}
which results in
\begin{code}
(+ 2 3) {\et -->} 5
\end{code}

The evaltrace environment is similar to the code environment, but by default it uses the et font instead of tt. Thus, it is useful for creating evaltrace diagrams in a ``WYSIWYG'' manner. The best way to show how this works is by giving a few examples.

    \begin{evaltrace}
    q-> {\tt (* 2 3)}
    |
    a-> {\tt 5}
    \end{evaltrace}
results in
\begin{evaltrace}
q-> {\tt (* 2 3)}
\vert
a-> {\tt 6}
\end{evaltrace}

It's a bit inconvenient to have to remember all of the character mappings, especially for more complicated diagrams. Thus, the evaltrace environment defines a number of special character sequences so that the ASCII representation of the diagrams looks more recognizable as an evaltrace diagram. For example:

    \begin{evaltrace}
    +--> ;(++ 2 3)
    |
    +_-> ;5
    \end{evaltrace}
produces
\begin{evaltrace}
+--> ;(++ 2 3)
\vert
+_-> ;5
\end{evaltrace}
Notice that +--> and +_-> produce upper and lower thin arrows with elbows (q-> and a->, respectively), and that the semi-colon tells LATEX to set the rest of the line in tt font. Notice also that since + is now a special character (it is actually an escape character just like \), we must write ++ to get a plus character.

The figures at the end of this document give several more examples, with some commentary. Also, the distribution contains the LATEX sources for the papers on evaltrace notation so that all of the examples in the paper can be examined.